字体、文本
2D字体
声明变量ID3DXFont* font = 0;
创建字体D3DXCreateFont(g_pd3dDevice, 36, 0, 0, 1000, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, 0, "黑体", &font);
绘制文本RECT rect = { 0, 0, width, height };
font->DrawText(NULL, TEXT("xiaojian"), -1, &rect, DT_LEFT | DT_TOP, D3DCOLOR_RGBA(0, 0, 0, 255));
3D字体
声明变量ID3DXMesh* Text = 0;
创建字体HDC hdc;
hdc = CreateCompatibleDC(0);
HFONT hfont, hfontold;
LOGFONT lf;
ZeroMemory(&lf, sizeof(LOGFONT));
lf.lfHeight = 35;
lf.lfWidth = 12;
lf.lfCharSet = DEFAULT_CHARSET;
wsprintf(lf.lfFaceName, TEXT("%s"), TEXT("黑体"));
hfont = CreateFontIndirect(&lf);
hfontold = (HFONT)SelectObject(hdc, hfont);
绘制文本D3DXCreateTextW(g_pd3dDevice, hdc, L"小贱", 0.001f, 0.4f, &Text, 0, 0);
SelectObject(hdc, hfontold);
DeleteObject(hfont);
DeleteDC(hdc);
g_pd3dDevice->SetMaterial(&white_mtrl);
Text->DrawSubset(0);
效果